package com.android.hamster.games;

import java.util.Random;

public class BoxField {

	public int largestArea;
	Random random = new Random();
	Box box1;
	Box box2;
	Box box3;
	Box box4;

	public BoxField() {

		box1 = new Box(30, 140, random.nextInt(75) + 25, random.nextInt(75) + 5);
		box2 = new Box(160, 140, random.nextInt(75) + 25, random.nextInt(75) + 25);
		box3 = new Box(30, 310, random.nextInt(75) + 25, random.nextInt(75) + 25);
		box4 = new Box(160, 310, random.nextInt(75) + 25, random.nextInt(75) + 25);

		if (box1.area > largestArea)
			largestArea = box1.area;
		if (box2.area > largestArea)
			largestArea = box2.area;
		if (box3.area > largestArea)
			largestArea = box3.area;
		if (box4.area > largestArea)
			largestArea = box4.area;

	}

	public int touch(int x, int y) {

		if (x > box1.x && x < box1.x + box1.width && y > box1.y && y < box1.y + box1.height)
			return box1.area;
		else if (x > box2.x && x < box2.x + box2.width && y > box2.y && y < box2.y + box2.height)
			return box2.area;
		else if (x > box3.x && x < box3.x + box3.width && y > box3.y && y < box3.y + box3.height)
			return box3.area;
		else if (x > box4.x && x < box4.x + box4.width && y > box4.y && y < box4.y + box4.height)
			return box4.area;
		else
			return 0;
	}
}
